# Maintainer: Jan Alexander Steffens (heftig) <jan.steffens@gmail.com>
# Contributor: Jan de Groot <jgc@archlinux.org>

pkgname=gst-plugins-bad
pkgver=1.14.4
pkgrel=3
pkgdesc="GStreamer Multimedia Framework Bad Plugins"
url="https://gstreamer.freedesktop.org/"
arch=(x86_64)
license=(LGPL)
depends=(mjpegtools gst-plugins-base-libs curl chromaprint libmms faad2 celt libdca libdvdnav
         libmodplug libgme wayland libofa openjpeg2 libwebp libsrtp gnutls sbc rtmpdump libgudev
         libexif libdvdread libvdpau libmpeg2 wildmidi ladspa openal libusb vulkan-icd-loader
         libfdk-aac faac soundtouch spandsp neon webrtc-audio-processing libdc1394 libmpcdec zvbi
         openexr libbs2b libnice lcms2 bluez-libs glu srt aom)
makedepends=(python gtk-doc autoconf-archive git gobject-introspection gtk3 vulkan-headers
             vulkan-validation-layers librsvg libtiger zbar fluidsynth lilv opencv)
_commit=566e4ecc223b18fce8bd932f5e4885f41f746dd4  # tags/1.14.4^0
source=("git+https://anongit.freedesktop.org/git/gstreamer/gst-plugins-bad#commit=$_commit"
        "gst-common::git+https://anongit.freedesktop.org/git/gstreamer/common"
        missing-includes.diff)
sha256sums=('SKIP'
            'SKIP'
            'acf625d58611372532bc76e7276dacd69d2a9f7dee88ed9e2e8ecae0881476a3')

pkgver() {
  cd $pkgname
  git describe --tags | sed 's/-/+/g'
}

prepare() {
  cd $pkgname

  # error: ‘CV_RGB’ was not declared in this scope
  patch -Np1 -i ../missing-includes.diff

  git submodule init
  git config --local submodule.common.url "$srcdir/gst-common"
  git submodule update

  NOCONFIGURE=1 ./autogen.sh
}

build() {
  cd $pkgname
  ./configure \
    --prefix=/usr \
    --sysconfdir=/etc \
    --localstatedir=/var \
    --libexecdir=/usr/lib \
    --with-package-name="GStreamer Bad Plugins (Arch Linux)" \
    --with-package-origin="https://www.archlinux.org/" \
    --with-gtk=3.0 \
    --enable-experimental \
    --enable-gtk-doc \
    --disable-static
  sed -i -e 's/ -shared / -Wl,-O1,--as-needed\0/g' libtool
  make
}

check() {
  cd $pkgname
  # bad tests are bad
  #make -k check || :
}

package() {
  cd $pkgname
  make DESTDIR="$pkgdir" install
}
